package com.mediacloud.app.newsmodule.view;

import android.widget.ImageView;
import android.widget.ImageView.ScaleType;

import com.mediacloud.app.assembly.photoview.PhotoViewAttacher;

public class PhotoViewAttacher4AppFactory extends PhotoViewAttacher {

	public PhotoViewAttacher4AppFactory(ImageView imageView) {
		super(imageView);
	}
	@Override
	protected void setImageViewScaleTypeMatrix(ImageView imageView) {
		if (null != imageView) {
			if (imageView instanceof PictureView) {
				/**
				 * PhotoView sets it's own ScaleType to Matrix, then diverts all
				 * calls setScaleType to this.setScaleType. Basically we don't
				 * need to do anything here
				 */
			} else {
				imageView.setScaleType(ScaleType.MATRIX);
			}
		}
	}
	@Override
	protected void checkImageViewScaleType() {
		ImageView imageView = getImageView();

		/**
		 * PhotoView's getScaleType() will just divert to this.getScaleType() so
		 * only call if we're not attached to a PhotoView.
		 */
		if (null != imageView && !(imageView instanceof PictureView)) {
			if (imageView.getScaleType() != ScaleType.MATRIX) {
				throw new IllegalStateException(
						"The ImageView's ScaleType has been changed since attaching a PhotoViewAttacher");
			}
		}
	}
}